package demo;

import org.junit.Test;

import java.time.Duration;
import java.time.Instant;
import java.util.stream.LongStream;

/**
 * @Author: WWQ
 * @Date: 2019/4/8 17:35
 * @Version 1.0
 */
public class ForkJoin {

    /**
     * java8的并行流
     */
    @Test
    public void test1(){
        Instant start=Instant.now();
        Long l=LongStream.rangeClosed(0,1000000000L)
                  .parallel()
                  .reduce(0,Long::sum);
        System.out.println(l);
        Instant end=Instant.now();
        System.out.println("消耗时间："+ Duration.between(start,end).toMillis());

    }
}
